package algorithm;

/**
 * 计算阶乘  n!
 */
public class Factorial {

    public static int getValue(int n) throws Exception {
        if (n > 1) {
            return n * getValue(n - 1);
        } else if (n == 1) {
            return 1;
        } else if (n == 0) {
            return 0;
        } else {
            throw new Exception("参数不能小于0！");
        }
    }

    public static void main(String[] args) {
        try {
            System.out.println(getValue(1));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
